import"../shell/shell.js";import*as t from"../../core/common/common.js";import*as e from"../../core/i18n/i18n.js";import*as i from"../../ui/legacy/legacy.js";import*as n from"../../core/root/root.js";import*as o from"../../core/host/host.js";import*as r from"../../core/sdk/sdk.js";import*as a from"../../ui/legacy/components/utils/utils.js";import*as s from"../main/main.js";const l={throttling:"Throttling",showThrottling:"Show Throttling",goOffline:"Go offline",device:"device",throttlingTag:"throttling",enableSlowGThrottling:"Enable slow `3G` throttling",enableFastGThrottling:"Enable fast `3G` throttling",goOnline:"Go online"},c=e.i18n.registerUIStrings("panels/mobile_throttling/mobile_throttling-meta.ts",l),g=e.i18n.getLazilyComputedLocalizedString.bind(void 0,c);let d;async function m(){return d||(d=await import("../../panels/mobile_throttling/mobile_throttling.js")),d}i.ViewManager.registerViewExtension({location:"settings-view",id:"throttling-conditions",title:g(l.throttling),commandPrompt:g(l.showThrottling),order:35,loadView:async()=>(await m()).ThrottlingSettingsTab.ThrottlingSettingsTab.instance(),settings:["customNetworkConditions"]}),i.ActionRegistration.registerActionExtension({actionId:"network-conditions.network-offline",category:i.ActionRegistration.ActionCategory.NETWORK,title:g(l.goOffline),loadActionDelegate:async()=>(await m()).ThrottlingManager.ActionDelegate.instance(),tags:[g(l.device),g(l.throttlingTag)]}),i.ActionRegistration.registerActionExtension({actionId:"network-conditions.network-low-end-mobile",category:i.ActionRegistration.ActionCategory.NETWORK,title:g(l.enableSlowGThrottling),loadActionDelegate:async()=>(await m()).ThrottlingManager.ActionDelegate.instance(),tags:[g(l.device),g(l.throttlingTag)]}),i.ActionRegistration.registerActionExtension({actionId:"network-conditions.network-mid-tier-mobile",category:i.ActionRegistration.ActionCategory.NETWORK,title:g(l.enableFastGThrottling),loadActionDelegate:async()=>(await m()).ThrottlingManager.ActionDelegate.instance(),tags:[g(l.device),g(l.throttlingTag)]}),i.ActionRegistration.registerActionExtension({actionId:"network-conditions.network-online",category:i.ActionRegistration.ActionCategory.NETWORK,title:g(l.goOnline),loadActionDelegate:async()=>(await m()).ThrottlingManager.ActionDelegate.instance(),tags:[g(l.device),g(l.throttlingTag)]}),t.Settings.registerSettingExtension({storageType:t.Settings.SettingStorageType.Synced,settingName:"customNetworkConditions",settingType:t.Settings.SettingType.ARRAY,defaultValue:[]});const p={profiler:"Profiler",showProfiler:"Show Profiler",performance:"Performance",showPerformance:"Show Performance",startStopRecording:"Start/stop recording",showRecentTimelineSessions:"Show recent timeline sessions",record:"Record",stop:"Stop",startProfilingAndReloadPage:"Start profiling and reload page"},f=e.i18n.registerUIStrings("panels/js_profiler/js_profiler-meta.ts",p),h=e.i18n.getLazilyComputedLocalizedString.bind(void 0,f);let w,A;async function T(){return A||(A=await import("../../panels/profiler/profiler.js")),A}async function y(){return w||(w=await import("../../panels/timeline/timeline.js")),w}function R(t){return void 0===w?[]:t(w)}i.ViewManager.registerViewExtension({location:"panel",id:"js_profiler",title:h(p.profiler),commandPrompt:h(p.showProfiler),order:65,persistence:"permanent",experiment:n.Runtime.ExperimentName.JS_PROFILER_TEMP_ENABLE,loadView:async()=>(await T()).ProfilesPanel.JSProfilerPanel.instance()}),i.ActionRegistration.registerActionExtension({actionId:"profiler.js-toggle-recording",category:i.ActionRegistration.ActionCategory.JAVASCRIPT_PROFILER,title:h(p.startStopRecording),iconClass:"record-start",toggleable:!0,toggledIconClass:"record-stop",toggleWithRedColor:!0,contextTypes:()=>void 0===A?[]:(t=>[t.ProfilesPanel.JSProfilerPanel])(A),loadActionDelegate:async()=>(await T()).ProfilesPanel.JSProfilerPanel.instance(),bindings:[{platform:"windows,linux",shortcut:"Ctrl+E"},{platform:"mac",shortcut:"Meta+E"}]}),i.ActionRegistration.registerActionExtension({actionId:"timeline.show-history",loadActionDelegate:async()=>(await y()).TimelinePanel.ActionDelegate.instance(),category:i.ActionRegistration.ActionCategory.PERFORMANCE,title:h(p.showRecentTimelineSessions),contextTypes:()=>R((t=>[t.TimelinePanel.TimelinePanel])),bindings:[{platform:"windows,linux",shortcut:"Ctrl+H"},{platform:"mac",shortcut:"Meta+Y"}]}),i.ActionRegistration.registerActionExtension({actionId:"timeline.toggle-recording",category:i.ActionRegistration.ActionCategory.PERFORMANCE,iconClass:"record-start",toggleable:!0,toggledIconClass:"record-stop",toggleWithRedColor:!0,contextTypes:()=>R((t=>[t.TimelinePanel.TimelinePanel])),loadActionDelegate:async()=>(await y()).TimelinePanel.ActionDelegate.instance(),options:[{value:!0,title:h(p.record)},{value:!1,title:h(p.stop)}],bindings:[{platform:"windows,linux",shortcut:"Ctrl+E"},{platform:"mac",shortcut:"Meta+E"}]}),i.ActionRegistration.registerActionExtension({actionId:"timeline.record-reload",iconClass:"refresh",contextTypes:()=>R((t=>[t.TimelinePanel.TimelinePanel])),category:i.ActionRegistration.ActionCategory.PERFORMANCE,title:h(p.startProfilingAndReloadPage),loadActionDelegate:async()=>(await y()).TimelinePanel.ActionDelegate.instance(),bindings:[{platform:"windows,linux",shortcut:"Ctrl+Shift+E"},{platform:"mac",shortcut:"Meta+Shift+E"}]});const u={main:"Main"},P=e.i18n.registerUIStrings("entrypoints/js_app/js_app.ts",u),S=e.i18n.getLocalizedString.bind(void 0,P);let E;class C{static instance(t={forceNew:null}){const{forceNew:e}=t;return E&&!e||(E=new C),E}async run(){o.userMetrics.actionTaken(o.UserMetrics.Action.ConnectToNodeJSDirectly),r.Connections.initMainConnection((async()=>{r.TargetManager.TargetManager.instance().createTarget("main",S(u.main),r.Target.Type.Node,null).runtimeAgent().invoke_runIfWaitingForDebugger()}),a.TargetDetachedDialog.TargetDetachedDialog.webSocketConnectionLost)}}t.Runnable.registerEarlyInitializationRunnable(C.instance),new s.MainImpl.MainImpl;export{C as JsMainImpl};
